from pygeotools.lib import geolib,iolib,warplib,malib
import numpy as np
import os,sys,glob,shutil
import matplotlib.pyplot as plt
from imview import pltlib
from autoRIFT import autoRIFT
This is the Open Source version of ISCE.
Some of the workflows depend on a separate licensed package.
To obtain the licensed package, please make a request for ISCE
through the website: https://download.jpl.nasa.gov/ops/request/index.cfm.
Alternatively, if you are a member, or can become a member of WinSAR
you may be able to obtain access to a version of the licensed sofware at
https://winsar.unavco.org/software/isce
%matplotlib notebook
%cd /nobackup/sbhusha1/feature_tracking_wg/
/nobackupp11/sbhusha1/feature_tracking_wg
integer pixel shifts¶
vx_integer = 'vx_integer.tif'
vy_integer = 'vy_integer.tif'
spm1_refinement = sorted(glob.glob('./multipixel_shifts/*multi_pixel_synthetic_shift*spm1/*spm1*-F.tif'))
f,ax = plt.subplots(1,2,figsize=(1,4))
vx_solved,vy_solved = [iolib.fn_getma(spm1_refinement[-1],x) for x in [1,2]]
pltlib.iv(vx_solved,cmap='inferno',ax=ax[0],label='vx shift px')
pltlib.iv(vy_solved,cmap='inferno',ax=ax[1],label='vy shift px')
plt.tight_layout()
2021-04-13 14:18:33,587 - matplotlib.colorbar - DEBUG - locator: <matplotlib.colorbar._ColorbarAutoLocator object at 0x2aac9afbb850>
2021-04-13 14:18:33,588 - matplotlib.colorbar - DEBUG - Using auto colorbar locator <matplotlib.colorbar._ColorbarAutoLocator object at 0x2aac9afbb850> on colorbar
2021-04-13 14:18:33,589 - matplotlib.colorbar - DEBUG - Setting pcolormesh
2021-04-13 14:18:33,598 - matplotlib.colorbar - DEBUG - locator: <matplotlib.colorbar._ColorbarAutoLocator object at 0x2aac9afbb850>
2021-04-13 14:18:33,598 - matplotlib.colorbar - DEBUG - Using auto colorbar locator <matplotlib.colorbar._ColorbarAutoLocator object at 0x2aac9afbb850> on colorbar
2021-04-13 14:18:33,599 - matplotlib.colorbar - DEBUG - Setting pcolormesh
2021-04-13 14:18:34,091 - matplotlib.colorbar - DEBUG - locator: <matplotlib.colorbar._ColorbarAutoLocator object at 0x2aac9b2f1f70>
2021-04-13 14:18:34,092 - matplotlib.colorbar - DEBUG - Using auto colorbar locator <matplotlib.colorbar._ColorbarAutoLocator object at 0x2aac9b2f1f70> on colorbar
2021-04-13 14:18:34,093 - matplotlib.colorbar - DEBUG - Setting pcolormesh
2021-04-13 14:18:34,099 - matplotlib.colorbar - DEBUG - locator: <matplotlib.colorbar._ColorbarAutoLocator object at 0x2aac9b2f1f70>
2021-04-13 14:18:34,100 - matplotlib.colorbar - DEBUG - Using auto colorbar locator <matplotlib.colorbar._ColorbarAutoLocator object at 0x2aac9b2f1f70> on colorbar
2021-04-13 14:18:34,101 - matplotlib.colorbar - DEBUG - Setting pcolormesh
malib.get_stats_dict(vx_solved)
{'count': 8712663,
'min': -10.940814971923828,
'max': 3.5652694702148438,
'ptp': 14.506084442138672,
'mean': -4.282221873548765,
'std': 2.1356544728001357,
'nmad': 2.9537797880172727,
'med': -4.008022785186768,
'median': -4.008022785186768,
'p16': -6.993836402893066,
'p84': -1.9934555292129517,
'spread': 2.5001904368400574,
'mode': -6.0}
malib.get_stats_dict(vx_input)
{'count': 9222617,
'min': 1.0,
'max': 8.0,
'ptp': 7.0,
'mean': 4.296819763847941,
'std': 2.1817703366801298,
'nmad': 2.9652,
'med': 4.0,
'median': 4.0,
'p16': 2.0,
'p84': 7.0,
'spread': 2.5,
'mode': 7.0}
def box_plot_prep(synthetic_shift,computed_shift):
unique_vals = np.unique(synthetic_shift)
out_vals_list = []
for vals in unique_vals:
idx = synthetic_shift == vals
out_vals_list.append(computed_shift[idx].compressed())
return unique_vals.compressed(),out_vals_list[:-1]
%matplotlib notebook
f,axa = plt.subplots(2,5,figsize=(25,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in spm1_refinement]
vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
pltlib.iv(vx,ax=ax[idx],cmap='inferno',title=f'Kernel size: {kernels[idx]}')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in spm1_refinement]
vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
pltlib.iv(vy,ax=ax[idx+5],cmap='inferno')
plt.tight_layout()
/nobackupp11/sbhusha1/sw/imview/imview/lib/pltlib.py:146: MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. In future versions, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = copy.copy(mpl.cm.get_cmap("inferno"))
cmap.set_bad('0.5', alpha=1)
def plot_synthetic_boxplot(ax,v_input,v_output):
v_input = np.ma.array(v_input,mask=v_output.mask)
box_x,box_y = box_plot_prep(v_input,-1*v_output)
ax.boxplot(box_y, positions=box_x, sym='', widths=0.6,whis=(5,95))
ax.grid(linestyle='--')
f,axa = plt.subplots(2,5,figsize=(25,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
# plot the x component first
vx_input = iolib.fn_getma(vx_integer)
vy_input = iolib.fn_getma(vy_integer)
vx_list = [iolib.fn_getma(x,1) for x in spm1_refinement]
vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
plot_synthetic_boxplot(ax[idx],vx_input,vx)
ax[idx].set_title(f'Kernel size: {kernels[idx]}')
ax[idx].set_xlabel('Input x shift (px)')
ax[idx].set_ylabel('Measured x shift (px)')
#vx,ax=ax[idx],cmap='inferno',title=f'Kernel size: {kernels[idx]}')
# now plot the y component
vy_list = [iolib.fn_getma(x,2) for x in spm1_refinement]
vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
plot_synthetic_boxplot(ax[idx+5],vy_input,vy)
ax[idx+5].set_xlabel('Input y shift (px)')
ax[idx+5].set_ylabel('Measured y shift (px)')
plt.tight_layout()
Fix kernel size change the spm mode¶
Kernel size = 9¶
kernel9_results = sorted(glob.glob('./multipixel_shifts/*multi_pixel_synthetic_shift*9px*spm*/*spm*-F.tif'))
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in kernel9_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
pltlib.iv(vx,ax=ax[idx],cmap='inferno',title=f'{refinement[idx]} refinement')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in kernel9_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
pltlib.iv(vy,ax=ax[idx+3],cmap='inferno')
plt.tight_layout()
/nobackupp11/sbhusha1/sw/imview/imview/lib/pltlib.py:146: MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. In future versions, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = copy.copy(mpl.cm.get_cmap("inferno"))
cmap.set_bad('0.5', alpha=1)
window sizes for affine adaptive and adaptive windows should be higher.
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
vx_input = iolib.fn_getma(vx_integer)
vy_input = iolib.fn_getma(vy_integer)
vx_list = [iolib.fn_getma(x,1) for x in kernel9_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
plot_synthetic_boxplot(ax[idx],vx_input,vx)
ax[idx].set_title(f'{refinement[idx]} refinement')
ax[idx].set_xlabel('Input x shift (px)')
ax[idx].set_ylabel('Measured x shift (px)')
#vx,ax=ax[idx],cmap='inferno',title=f'Kernel size: {kernels[idx]}')
# now plot the y component
vy_list = [iolib.fn_getma(x,2) for x in kernel9_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
plot_synthetic_boxplot(ax[idx+3],vy_input,vy)
ax[idx+3].set_xlabel('Input y shift (px)')
ax[idx+3].set_ylabel('Measured y shift (px)')
plt.tight_layout()
Fix kernel size change the spm mode¶
Kernel size = 35¶
kernel35_results = sorted(glob.glob('./multipixel_shifts/*multi_pixel_synthetic_shift*35px*spm*/*spm*-F.tif'))
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in kernel35_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
pltlib.iv(vx,ax=ax[idx],cmap='inferno',title=f'{refinement[idx]} refinement')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in kernel35_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
pltlib.iv(vy,ax=ax[idx+3],cmap='inferno')
plt.tight_layout()
/nobackupp11/sbhusha1/sw/imview/imview/lib/pltlib.py:146: MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. In future versions, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = copy.copy(mpl.cm.get_cmap("inferno"))
cmap.set_bad('0.5', alpha=1)
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
vx_input = iolib.fn_getma(vx_integer)
vy_input = iolib.fn_getma(vy_integer)
vx_list = [iolib.fn_getma(x,1) for x in kernel35_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
plot_synthetic_boxplot(ax[idx],vx_input,vx)
ax[idx].set_title(f'{refinement[idx]} refinement')
ax[idx].set_xlabel('Input x shift (px)')
ax[idx].set_ylabel('Measured x shift (px)')
#vx,ax=ax[idx],cmap='inferno',title=f'Kernel size: {kernels[idx]}')
# now plot the y component
vy_list = [iolib.fn_getma(x,2) for x in kernel35_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
plot_synthetic_boxplot(ax[idx+3],vy_input,vy)
ax[idx+3].set_xlabel('Input y shift (px)')
ax[idx+3].set_ylabel('Measured y shift (px)')
plt.tight_layout()
Fix kernel size change the spm mode¶
Kernel size = 15¶
kernel15_results = sorted(glob.glob('./multipixel_shifts/*multi_pixel_synthetic_shift*15px*spm*/*spm*-F.tif'))
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in kernel15_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
pltlib.iv(vx,ax=ax[idx],cmap='inferno',title=f'{refinement[idx]} refinement')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in kernel15_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
pltlib.iv(vy,ax=ax[idx+3],cmap='inferno')
plt.tight_layout()
/nobackupp11/sbhusha1/sw/imview/imview/lib/pltlib.py:146: MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. In future versions, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = copy.copy(mpl.cm.get_cmap("inferno"))
cmap.set_bad('0.5', alpha=1)
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
vx_input = iolib.fn_getma(vx_integer)
vy_input = iolib.fn_getma(vy_integer)
vx_list = [iolib.fn_getma(x,1) for x in kernel15_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
plot_synthetic_boxplot(ax[idx],vx_input,vx)
ax[idx].set_title(f'{refinement[idx]} refinement')
ax[idx].set_xlabel('Input x shift (px)')
ax[idx].set_ylabel('Measured x shift (px)')
#vx,ax=ax[idx],cmap='inferno',title=f'Kernel size: {kernels[idx]}')
# now plot the y component
vy_list = [iolib.fn_getma(x,2) for x in kernel15_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
plot_synthetic_boxplot(ax[idx+3],vy_input,vy)
ax[idx+3].set_xlabel('Input y shift (px)')
ax[idx+3].set_ylabel('Measured y shift (px)')
plt.tight_layout()
Spread in the observed values is lower in affine adaptive and affine measurements when compared to parabolic subpixel shifts, but might have some blunders.¶
Results with kernel size of 51 px¶
kernel51_results = sorted(glob.glob('./multipixel_shifts/*multi_pixel_synthetic_shift*51px*spm*/*spm*-F.tif'))
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
vx_input = iolib.fn_getma(vx_integer)
vy_input = iolib.fn_getma(vy_integer)
vx_list = [iolib.fn_getma(x,1) for x in kernel51_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
plot_synthetic_boxplot(ax[idx],vx_input,vx)
ax[idx].set_title(f'{refinement[idx]} refinement')
ax[idx].set_xlabel('Input x shift (px)')
ax[idx].set_ylabel('Measured x shift (px)')
#vx,ax=ax[idx],cmap='inferno',title=f'Kernel size: {kernels[idx]}')
# now plot the y component
vy_list = [iolib.fn_getma(x,2) for x in kernel51_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
plot_synthetic_boxplot(ax[idx+3],vy_input,vy)
ax[idx+3].set_xlabel('Input y shift (px)')
ax[idx+3].set_ylabel('Measured y shift (px)')
plt.tight_layout()
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in kernel51_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
pltlib.iv(vx,ax=ax[idx],cmap='inferno',title=f'{refinement[idx]} refinement')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in kernel51_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
pltlib.iv(vy,ax=ax[idx+3],cmap='inferno')
plt.tight_layout()
/nobackupp11/sbhusha1/sw/imview/imview/lib/pltlib.py:146: MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. In future versions, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = copy.copy(mpl.cm.get_cmap("inferno"))
cmap.set_bad('0.5', alpha=1)
Measurements with deformation shifts¶
vx_deformation = 'vx_deformation.tif'
vy_deformation = 'vy_deformation.tif'
spm1_refinement = sorted(glob.glob('./multipixel_shifts/*deformation_synthetic_shift*spm1/*spm1*-F.tif'))
f,ax = plt.subplots(1,2)
pltlib.iv_fn(vx_deformation,ax=ax[0],label='Input vx deformation (px)',
scalebar=False,cmap='RdBu',clim=(-3,3))
pltlib.iv_fn(vy_deformation,ax=ax[1],label='Input vy deformation (px)',
scalebar=False,cmap='RdBu',clim=(-5,5))
/nobackupp11/sbhusha1/sw/imview/imview/lib/pltlib.py:149: MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. In future versions, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = copy.copy(mpl.cm.get_cmap("RdBu"))
cmap.set_bad('k', alpha=1)
<AxesSubplot:>
def plot_scatter(ax,v_input,v_output):
mask = malib.common_mask([v_input,v_output])
v_input = np.ma.array(v_input,mask=mask)
v_output = -1*np.ma.array(v_output,mask=mask)
ax.scatter(v_input.compressed(),v_output.compressed(),s=1,c='r')
#ax.hist2d(v_input.compressed(),v_output.compressed(),bins=50,cmap='inferno')
# median absolute difference formula from here: https://en.wikipedia.org/wiki/Mean_absolute_difference
# I changed the n2 to n, where n is the number of observations
mad = np.round(np.sum(np.abs(v_input.compressed()-v_output.compressed()))/(v_input.count()),2)
ax.text(x=0.75,y=0.9,
s=f'CORR = {np.round(np.corrcoef(v_input.compressed(),v_output.compressed())[0,1],3)}\n MAD = {mad}',transform=ax.transAxes)
ax.grid(linestyle='--')
f,axa = plt.subplots(2,5,figsize=(25,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in spm1_refinement]
vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
pltlib.iv(vx,ax=ax[idx],cmap='RdBu',clim=malib.calcperc_sym(vx,perc=(2,98)),
title=f'Kernel size: {kernels[idx]}')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in spm1_refinement]
vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
pltlib.iv(vy,ax=ax[idx+5],cmap='RdBu',clim=malib.calcperc_sym(vy,perc=(2,98)))
plt.tight_layout()
f,axa = plt.subplots(2,5,figsize=(25,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in spm1_refinement]
vx_list = [vx_list[-1]] + vx_list[:-1]
vx_clim = (-10,10)
vy_clim = (-20,10)
for idx,vx in enumerate(vx_list):
vx_in = iolib.fn_getma(vx_deformation)
plot_scatter(ax[idx],vx_in,vx)
ax[idx].set_xlabel('Input vx shift(px)')
ax[idx].set_ylabel('Measured vx shift(px)')
ax[idx].set_title(f'Kernel size: {kernels[idx]}')
ax[idx].set_xlim(vx_clim[0],vx_clim[1])
ax[idx].set_ylim(vx_clim[0],vx_clim[1])
#pltlib.iv(vx,ax=ax[idx],cmap='RdBu',clim=malib.calcperc_sym(vx,perc=(2,98)),
# title=f'Kernel size: {kernels[idx]}')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in spm1_refinement]
vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
#pltlib.iv(vy,ax=ax[idx+5],cmap='RdBu',clim=malib.calcperc_sym(vy,perc=(2,98)))
vy_in = iolib.fn_getma(vy_deformation)
plot_scatter(ax[idx+5],vy_in,vy)
ax[idx+5].set_xlabel('Input vy shift(px)')
ax[idx+5].set_ylabel('Measured vy shift(px)')
ax[idx+5].set_title(f'Kernel size: {kernels[idx]}')
ax[idx+5].set_xlim(vy_clim[0],vy_clim[1])
ax[idx+5].set_ylim(vy_clim[0],vy_clim[1])
plt.tight_layout()
spm 2¶
vx_deformation = 'vx_deformation.tif'
vy_deformation = 'vy_deformation.tif'
spm2_refinement = sorted(glob.glob('./multipixel_shifts/*deformation_synthetic_shift*spm2/*spm2*-F.tif'))
f,axa = plt.subplots(2,5,figsize=(25,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in spm2_refinement]
vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
pltlib.iv(vx,ax=ax[idx],cmap='RdBu',clim=malib.calcperc_sym(vx,perc=(2,98)),
title=f'Kernel size: {kernels[idx]}')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in spm2_refinement]
vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
pltlib.iv(vy,ax=ax[idx+5],cmap='RdBu',clim=malib.calcperc_sym(vy,perc=(2,98)))
plt.tight_layout()
/nobackupp11/sbhusha1/sw/imview/imview/lib/pltlib.py:149: MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. In future versions, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = copy.copy(mpl.cm.get_cmap("RdBu"))
cmap.set_bad('k', alpha=1)
f,axa = plt.subplots(2,5,figsize=(25,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in spm2_refinement]
vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
vx_in = iolib.fn_getma(vx_deformation)
plot_scatter(ax[idx],vx_in,vx)
ax[idx].set_xlabel('Input vx shift(px)')
ax[idx].set_ylabel('Measured vx shift(px)')
ax[idx].set_title(f'Kernel size: {kernels[idx]}')
#pltlib.iv(vx,ax=ax[idx],cmap='RdBu',clim=malib.calcperc_sym(vx,perc=(2,98)),
# title=f'Kernel size: {kernels[idx]}')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in spm2_refinement]
vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
#pltlib.iv(vy,ax=ax[idx+5],cmap='RdBu',clim=malib.calcperc_sym(vy,perc=(2,98)))
vy_in = iolib.fn_getma(vy_deformation)
plot_scatter(ax[idx+5],vy_in,vy)
ax[idx+5].set_xlabel('Input vy shift(px)')
ax[idx+5].set_ylabel('Measured vy shift(px)')
ax[idx+5].set_title(f'Kernel size: {kernels[idx]}')
plt.tight_layout()
spm3¶
vx_deformation = 'vx_deformation.tif'
vy_deformation = 'vy_deformation.tif'
spm3_refinement = sorted(glob.glob('./multipixel_shifts/*deformation_synthetic_shift*spm3/*spm3*-F.tif'))
f,axa = plt.subplots(2,5,figsize=(25,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in spm3_refinement]
vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
pltlib.iv(vx,ax=ax[idx],cmap='RdBu',clim=malib.calcperc_sym(vx,perc=(2,98)),
title=f'Kernel size: {kernels[idx]}')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in spm3_refinement]
vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
pltlib.iv(vy,ax=ax[idx+5],cmap='RdBu',clim=malib.calcperc_sym(vy,perc=(2,98)))
plt.tight_layout()
f,axa = plt.subplots(2,5,figsize=(25,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
# plot the x component first
vx_list = [iolib.fn_getma(x,1) for x in spm3_refinement]
vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
vx_in = iolib.fn_getma(vx_deformation)
plot_scatter(ax[idx],vx_in,vx)
ax[idx].set_xlabel('Input vx shift(px)')
ax[idx].set_ylabel('Measured vx shift(px)')
ax[idx].set_title(f'Kernel size: {kernels[idx]}')
#pltlib.iv(vx,ax=ax[idx],cmap='RdBu',clim=malib.calcperc_sym(vx,perc=(2,98)),
# title=f'Kernel size: {kernels[idx]}')
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in spm3_refinement]
vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
#pltlib.iv(vy,ax=ax[idx+5],cmap='RdBu',clim=malib.calcperc_sym(vy,perc=(2,98)))
vy_in = iolib.fn_getma(vy_deformation)
plot_scatter(ax[idx+5],vy_in,vy)
ax[idx+5].set_xlabel('Input vy shift(px)')
ax[idx+5].set_ylabel('Measured vy shift(px)')
ax[idx+5].set_title(f'Kernel size: {kernels[idx]}')
plt.tight_layout()
For affine adaptive and affine refinement method, small kernel sizes produce the most offset, but get bets result with medium to big kernel sizes.¶
Fix kernel size change the spm mode¶
Kernel size = 35¶
kernel35_results = sorted(glob.glob('./multipixel_shifts/*deformation_synthetic_shift*35px*spm*/*spm*-F.tif'))
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
clim_x = (-3,3)
clim_y = (-5,5)
vx_list = [iolib.fn_getma(x,1) for x in kernel35_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
pltlib.iv(vx,ax=ax[idx],cmap='RdBu',title=f'{refinement[idx]} refinement',
clim=clim_x)
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in kernel35_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
pltlib.iv(vy,ax=ax[idx+3],cmap='RdBu',clim=clim_y)
plt.tight_layout()
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
vx_input = iolib.fn_getma(vx_deformation)
vy_input = iolib.fn_getma(vy_deformation)
vx_list = [iolib.fn_getma(x,1) for x in kernel35_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
plot_scatter(ax[idx],vx_input,vx)
ax[idx].set_title(f'{refinement[idx]} refinement')
ax[idx].set_xlabel('Input x shift (px)')
ax[idx].set_ylabel('Measured x shift (px)')
#vx,ax=ax[idx],cmap='inferno',title=f'Kernel size: {kernels[idx]}')
# now plot the y component
vy_list = [iolib.fn_getma(x,2) for x in kernel35_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
plot_scatter(ax[idx+3],vy_input,vy)
#plot_synthetic_boxplot(ax[idx+3],vy_input,vy)
ax[idx+3].set_xlabel('Input y shift (px)')
ax[idx+3].set_ylabel('Measured y shift (px)')
plt.tight_layout()
Kernel size of 9 px¶
kernel9_results = sorted(glob.glob('./multipixel_shifts/*deformation_synthetic_shift*9px*spm*/*spm*-F.tif'))
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
clim_x = (-3,3)
clim_y = (-5,5)
vx_list = [iolib.fn_getma(x,1) for x in kernel9_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
pltlib.iv(vx,ax=ax[idx],cmap='RdBu',title=f'{refinement[idx]} refinement',
clim=clim_x)
# now plot the y component first
vy_list = [iolib.fn_getma(x,2) for x in kernel9_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
pltlib.iv(vy,ax=ax[idx+3],cmap='RdBu',clim=clim_y)
plt.tight_layout()
/nobackupp11/sbhusha1/sw/imview/imview/lib/pltlib.py:149: MatplotlibDeprecationWarning: You are modifying the state of a globally registered colormap. In future versions, you will not be able to modify a registered colormap in-place. To remove this warning, you can make a copy of the colormap first. cmap = copy.copy(mpl.cm.get_cmap("RdBu"))
cmap.set_bad('k', alpha=1)
f,axa = plt.subplots(2,3,figsize=(15,8))
ax = axa.ravel()
kernels = [9,15,25,35,51]
refinement = ['parabolic','affine adatptive','affine']
# plot the x component first
vx_input = iolib.fn_getma(vx_deformation)
vy_input = iolib.fn_getma(vy_deformation)
vx_list = [iolib.fn_getma(x,1) for x in kernel9_results]
#vx_list = [vx_list[-1]] + vx_list[:-1]
for idx,vx in enumerate(vx_list):
plot_scatter(ax[idx],vx_input,vx)
ax[idx].set_title(f'{refinement[idx]} refinement')
ax[idx].set_xlabel('Input x shift (px)')
ax[idx].set_ylabel('Measured x shift (px)')
#vx,ax=ax[idx],cmap='inferno',title=f'Kernel size: {kernels[idx]}')
# now plot the y component
vy_list = [iolib.fn_getma(x,2) for x in kernel9_results]
#vy_list = [vy_list[-1]] + vy_list[:-1]
for idx,vy in enumerate(vy_list):
plot_scatter(ax[idx+3],vy_input,vy)
#plot_synthetic_boxplot(ax[idx+3],vy_input,vy)
ax[idx+3].set_xlabel('Input y shift (px)')
ax[idx+3].set_ylabel('Measured y shift (px)')
plt.tight_layout()